package com.gm.wj.controller;


import com.gm.wj.entity.WorkPublish;
import com.gm.wj.result.Result;
import com.gm.wj.result.ResultFactory;
import com.gm.wj.service.WorkPublishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/workPublish")
public class WorkPublishController {

    @Autowired
    private WorkPublishService workPublishService;


    /**
     * 删除
     * @param id
     * @return
     */
    @GetMapping("/get/{id}")
    public Result get(@PathVariable("id") Integer id) {
        return ResultFactory.buildSuccessResult(workPublishService.getById(id));
    }



    /**
     * 获取列表
     * @return
     */
    @GetMapping("/list")
    public Result list() {
        return ResultFactory.buildSuccessResult(workPublishService.list());
    }

    /**
     * 保存
     * @param entity
     * @return
     */
    @PostMapping("/save")
    public Result save(@RequestBody WorkPublish entity) {
        return ResultFactory.buildSuccessResult(workPublishService.save(entity));
    }


    /**
     * 删除
     * @param ids
     * @return
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody List<Integer> ids) {
        return ResultFactory.buildSuccessResult(workPublishService.deleteById(ids));
    }

}
